package com.Txunda.fxw.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.Txunda.fxw.R;
import com.Txunda.fxw.base.utils.tool.DateTool;
import com.Txunda.fxw.base.utils.tool.Toolkit;
import com.Txunda.fxw.ui.adapter.base.BaseAdapterForLvOrGv;
import com.Txunda.fxw.ui.adapter.base.BaseViewHolder;
import com.Txunda.fxw.view.RoundedImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import java.util.Map;

import butterknife.BindView;

/**
 * =======================================
 * 作   者：Hwangzj
 * 创建时间：2018/11/15 0:52
 * 代码描述：
 * 修改历史：
 * 说   明：
 * =======================================
 */
public class VideoFeedAdapter extends BaseAdapterForLvOrGv<Map<String, String>, VideoFeedAdapter.VideoVh> {
    private int size;

    public VideoFeedAdapter(Context context) {
        super(context);
        size = Toolkit.dip2px(context, 56);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_video_feed_lv;
    }

    @Override
    protected VideoVh createViewHolder(View view) {
        return new VideoVh(view);
    }

    @Override
    protected void bindViewData(int position, VideoVh videoVh, Map<String, String> item) {
        Glide.with(context)
                .load(item.get("head_pic"))
                .override(size, size)
                .centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .into(videoVh.userHeaderIv);

        videoVh.userNameTv.setText(item.get("nickname"));
        videoVh.feedTimeTv.setText(DateTool.timeStamp2Date(item.get("ctime"), "yyyy-MM-dd hh:mm:ss"));
        videoVh.feedContentTv.setText(item.get("content"));

        if (item.get("BusinessReply") == null || item.get("BusinessReply").equals("null") || item.get("BusinessReply").equals("")) {
            videoVh.ll_gone.setVisibility(View.GONE);
        } else {
            videoVh.ll_gone.setVisibility(View.VISIBLE);
            videoVh.text_context.setText(item.get("BusinessReply"));
        }

    }


    class VideoVh extends BaseViewHolder {
        @BindView(R.id.user_header_iv)
        RoundedImageView userHeaderIv;
        @BindView(R.id.user_name_tv)
        TextView userNameTv;
        @BindView(R.id.feed_time_tv)
        TextView feedTimeTv;
        @BindView(R.id.feed_content_tv)
        TextView feedContentTv;
        @BindView(R.id.ll_gone)
        LinearLayout ll_gone;
        @BindView(R.id.text_context)
        TextView text_context;

        public VideoVh(View itemView) {
            super(itemView);
        }
    }

}
